import unittest
from ddt import ddt, data, unpack

# @ddt
# class MyTestCase(unittest.TestCase):
    # 元组数据
    # @data((1, 2), (3, 4), (5, 6))
    # def test1(self, value1, value2, value3):
    #     print(value1, value2, value3)

    # 列表数据
    # @data([1, 2], [3, 4], [5, 6])
    # def test2(self, value1, value2, value3):
    #     print(value1, value2, value3)

    # # 字典数据
    # @data({"name": "张三", "age": "14"}, {"name": "李四", "age": "15"})
    # # def test3(self, value):
    # #     print(value)
    # @unpack  # 可以将 元组、列表、字典 等类型的值拆分出来
    # def test4(self, name, age):
    #     print(name, age)

# # 变量结合ddt
# testdata = [{"name": "张三", "age": "14"}, {"name": "李四", "age": "15"}]
#
# @ddt
# class MyTestCase(unittest.TestCase):
#     @data(*testdata)
#     def test(self, value):
#         print(value)
#     @unpack  # 可以将 元组、列表、字典 等类型的值拆分出来
#     def test4(self, name, age):
#     print(name, age)


# 方法与ddt结合
from CSV.DoCsv import ReadCsv


def get_data():
    testdata = [{"name": "张三", "age": "14"}, {"name": "李四", "age": "15"}]
    return testdata

@ddt
class MyTestCase(unittest.TestCase):
    @data(ReadCsv())    # 引用csv数据读取文件
    def test(self, value):
        print(value)
        for row in value:
            print(row)
    # @unpack  # 可以将 元组、列表、字典 等类型的值拆分出来
    # def test4(self, data1, data2):
    #     print(data1, data2)
    #     print(data1.get("name"))


if __name__ == '__main__':
    unittest.main()
































